﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PloobsEngine.Utils
{
    public class BundleHandler
    {
        /// <summary>
        /// Le arquivos com informacoes do tipo a=b e retorna um dicionario com chaves a e 
        /// values b
        /// </summary>
        /// <param name="filename">nome do arquivo</param>
        /// <returns>dicionario contendo as informacoes</returns>
        public static IDictionary<String, String> getBundle(string filename)
        {
            //C:\Users\Rosana Nobre\Desktop\Engine\Engine\bin\x86\Debug\Content\Factories
            IDictionary<String,String> dic = new Dictionary<String,String>();
            StreamReader sr =  File.OpenText(filename);
            String line = sr.ReadLine();
            while ( line != null  )
            {
                if (!line.StartsWith("%") && line != "")
                {
                string word1 = line.Substring(0,line.IndexOf('='));
                string word2 = line.Substring(line.IndexOf('=') + 1);
                dic.Add(word1, word2);
                }
                line = sr.ReadLine();
                
            }
            sr.Close();
            return dic;
            
        }
    }

}
